package br.ufmg.vod.wbr.algorithims.bfs;

import br.ufmg.vod.collections.IntQueue;
import br.ufmg.vod.collections.IntQueueStack;
import br.ufmg.vod.wbr.api.Graph;

public class BFSData{
	
	public static byte WHITE = 0;
	public static byte GRAY = 1;
	public static byte BLACK = 2;
	
	
	Graph graph;
	public int time;
	public int[] predecessor;
	public int[] dist;
	public int[] discoveryTime;
	public int[] closeTime;
	public byte[] colors;
	public int startVertex;
	public IntQueue visitedQueue;
	public int maxDist;
	public double avgDist;
	public int minPathCount;
	
	
	public BFSData(Graph g){

		this.graph = g;
		this.time=0;
		this.predecessor = new int[g.getNumVertex()];
		this.discoveryTime = new int[g.getNumVertex()];
		this.closeTime = new int[g.getNumVertex()];
		this.colors = new byte[g.getNumVertex()];
		this.visitedQueue = new IntQueueStack(g.getNumVertex());
		this.dist = new int[g.getNumVertex()];
		this.maxDist = 0;
		this.avgDist = 0;
		this.minPathCount = 0;
		
		this.clearAllData();
	}


	public void clearAllData() {

		for (int i = 0; i < this.graph.getNumVertex(); i++) {
			this.predecessor[i]=-1;
			this.dist[i]= Integer.MAX_VALUE;
			this.discoveryTime[i]=-1;
			this.closeTime[i]=-1;
			this.colors[i]=WHITE;
		}
		this.visitedQueue.clear();
	}
	
	public void clearVisitedData() {
		while(!this.visitedQueue.isEmpty()){
			int i = this.visitedQueue.dequeue();
			this.predecessor[i]=-1;
			this.dist[i]= Integer.MAX_VALUE;
			this.discoveryTime[i]=-1;
			this.closeTime[i]=-1;
			this.colors[i]=WHITE;
		}
		this.avgDist=0.0;
		this.maxDist=0;
		this.minPathCount=0;
		this.visitedQueue.clear();
	}
	
	
}
